<?php
    interface Shape
    {
        function draw();
    }

    class Circle implements Shape
    {
        public function draw()
        {
            echo 'circle draw' . PHP_EOL;
        }
    }

    class Square implements Shape
    {
        function draw()
        {
            echo 'circle draw' . PHP_EOL;
        }
    }

    class ShapeFactory
    {
        public static function getShape($shape)
        {
            try {
                $class = ucfirst($shape);
                return new $class;
            } catch (Exception $ex) {
                echo $ex->getMessage() . PHP_EOL;
            } finally {
                echo __METHOD__ . PHP_EOL;
            }
        }
    }

    $shape = new Circle;
    $shape->draw();

    $shape = new Square;
    $shape->draw();

    ShapeFactory::getShape('square')->draw();
